package io;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

import manager.Manager;

import entities.Course;


public class TimeTablesReader extends CSVReader {

	public ArrayList<Course> getTimeTableEntries() throws FileNotFoundException, IOException {
		
		ArrayList<Course> timeTableEntries = new ArrayList<Course>();

		ArrayList<ArrayList<String>> csvContent = this.readFile("course.csv");
		for(ArrayList<String> csvRow : csvContent) {
			Course t_time_table_entry = new Course();
			t_time_table_entry.set_ID(csvRow.get(0));
			t_time_table_entry.set_duration((int) Math.ceil(Double.parseDouble(csvRow.get(1))));
			t_time_table_entry.set_capacity(Integer.parseInt(csvRow.get(2)));
			t_time_table_entry.set_instructor(csvRow.get(3));
			
			timeTableEntries.add(t_time_table_entry);
		}
		
		return timeTableEntries;
	}
	
	// TODO implementation in cycle 3
	public void readFile() throws FileNotFoundException, IOException {
		ArrayList<Course> timeTableEntries = this.getTimeTableEntries();
		(new Manager()).validate(timeTableEntries);
	}
	
}
